package com.cmc.cloud.cmclink.doc.controller.admin;

import cn.hutool.core.bean.BeanUtil;
import com.cmc.cloud.cmclink.doc.vo.CustomsCountry56CreateReqVO;
import com.cmc.cloud.cmclink.doc.vo.CustomsCountry56PageReqVO;
import com.cmc.cloud.cmclink.doc.vo.CustomsCountry56RespVO;
import com.cmc.cloud.cmclink.doc.vo.CustomsCountry56UpdateReqVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import com.cmes.framework.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;


import com.cmes.framework.common.pojo.PageResult;

import com.cmc.cloud.cmclink.doc.entity.CustomsCountry56DO;
import com.cmc.cloud.cmclink.doc.service.CustomsCountry56Service;
import com.cmc.cloud.cmclink.doc.constants.UrlConstants;


/**
 * {table.classComment}前端接口Controller
 * 
 * @author codegen
 */
@Tag(name = "管理后台 - 国家56号令国家的标识符数据")
@RestController
@RequestMapping(UrlConstants.APPLICATION_URL+"/country")
@Validated
public class CustomsCountry56Controller {

    @Resource
    private CustomsCountry56Service customsCountry56Service;


    @Operation(summary = "创建国家56号令国家的标识符数据")
    @PostMapping("/create")
    public CommonResult<Boolean> createCustomsCountry56(@Valid @RequestBody CustomsCountry56CreateReqVO createReqVO) {
        customsCountry56Service.createCustomsCountry56(createReqVO);
        return CommonResult.success(true);
    }


    @Operation(summary = "更新国家56号令国家的标识符数据")
    @PostMapping("/update")
    public CommonResult<Void> updateCustomsCountry56(@Valid @RequestBody CustomsCountry56UpdateReqVO updateReqVO) {
        customsCountry56Service.updateCustomsCountry56(updateReqVO);
        return CommonResult.success();
    }


    @Operation(summary = "删除国家56号令国家的标识符数据")
    @Parameter(name = "id", description = "编号", required = true)
    @PostMapping("/delete/{id}")
    public CommonResult<Void> deleteCustomsCountry56(@PathVariable("id") Long id) {
        customsCountry56Service.deleteCustomsCountry56(id);
        return CommonResult.success();
    }


    @Operation(summary = "获得国家56号令国家的标识符数据")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @GetMapping("/getById/{id}")
    public CommonResult<CustomsCountry56RespVO> getCustomsCountry56(@PathVariable("id") Long id) {
        CustomsCountry56DO customsCountry56 = customsCountry56Service.getCustomsCountry56(id);
        return CommonResult.success(BeanUtil.copyProperties(customsCountry56, CustomsCountry56RespVO.class));
    }


    @Operation(summary = "获得国家56号令国家的标识符数据列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @GetMapping("/listAll")
    public CommonResult<List<CustomsCountry56RespVO>> getCustomsCountry56List(@RequestParam("ids") Collection<Long> ids) {
        List<CustomsCountry56DO> list = customsCountry56Service.getCustomsCountry56List(ids);
        return CommonResult.success(BeanUtil.copyToList(list,CustomsCountry56RespVO.class));
    }


    @Operation(summary = "获得国家56号令国家的标识符数据分页")
    @GetMapping("/getPage")
    @UseResponsePropertyAdvice
    public CommonResult<PageResult<CustomsCountry56RespVO>> getCustomsCountry56Page(@Valid @RequestBody CustomsCountry56PageReqVO pageVO) {
        PageResult<CustomsCountry56DO> pageResult = customsCountry56Service.getCustomsCountry56Page(pageVO);
        List<CustomsCountry56RespVO> results = BeanUtil.copyToList(pageResult.getList(),CustomsCountry56RespVO.class);
        return CommonResult.success(new PageResult<>(results,pageResult.getTotal()));
    }
}
